package edu.yctc.weblog.controller.impl;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import edu.yctc.weblog.constant.RequestAttributes;
import edu.yctc.weblog.constant.TemplatePath;
import edu.yctc.weblog.controller.ConfigController;
import edu.yctc.weblog.service.ConfigService;

@Controller
@RequestMapping(TemplatePath.S + TemplatePath.CONFIGURATIONS)
public class ConfigControllerImpl implements ConfigController {

    @Autowired
    private ConfigService configService;

    @Override
    @GetMapping(TemplatePath.CONFIGURATIONS_PAGE)
    public String showList(HttpServletRequest request) {
        request.setAttribute(RequestAttributes.PATH, RequestAttributes.VALUE_CONFIGURATIONS);
        request.setAttribute(RequestAttributes.CONFIGURATIONS, configService.getAllConfigs().getModule());
        return TemplatePath.ADMIN + TemplatePath.S + TemplatePath.CONFIGURATIONS_PAGE;
    }

}
